# 7.1 input(x),意思是打印出x之后等待用户输入一个值

message=input("Tell me something, and I will repeat it back to you: ")
print(message)

# 7.1.1 打招呼
name=input("Please enter your name: ")
print("Hello, "+name+"!")

## 将这个事先需要打印的x先定义出来

prompt="If you tell us who you are, we can personalize the messages you see."
prompt+="\nwhat is your first name?"### 注意这个+=，p=p+w

name=input(prompt)
print("\nHello, "+name+"!")


# 7.1.2 为了之后能够比较大小，输入的值要求是数字，整型int

age=input("How old are you?")
age=int(age)
print(age>=18)##测试一下这个数能不能作为数值用

height=input("How tall are you, in inches？")
height=int(height)

if height>=36:
    print('\nYou are tall enough to ride!')
else:
    print("\nYou'll be able to ride when you're a litter older.")

# 7.1.3求余数
print(4%3)
print(5%3)

# 奇数偶数判断
number=input("Enter a number, and I'll tell you if it's even or odd:")
number=int(number)

if number % 2==0:
    print("\nThe number "+str(number)+" is even.")
else:
    print("\nThe number "+str(number)+" is odd.")


# 7.2.1 while循环
current_number=1
while current_number<=5:
    print(current_number)
    current_number+=1

# 7.2.2quit就退出
prompt="\nTell me something, and I will repeat it back to you:"
prompt+="\nEnter 'quit' to end the program."
message=''
while message != 'quit':
    message=input(prompt)
    if message!='quit':
        print(message)

## 用False，Ture来决定是否退出
prompt="\nTell me something, and I will repeat it back to you:"
prompt+="\nEnter 'quit' to end the program."

active=True
while active:
    message=input(prompt)

    if message=='quit':
        active=False
    else:
        print(message)

# 用break退出
prompt="\nPlease enter the name of a city you have visitied:"
prompt+="\n(Enter 'quit' when you are finished.)"

while True:
    city=input(prompt)
    if city == 'quit':
        break
    else:
        print("I'd love to go to "+city.title()+"!")


#continue 忽略之后的代码
current_number=0
while current_number<10:
    current_number+=1
    if current_number % 2 ==0:
        continue
    print(current_number)

# 7.3.1 从一个列表，转移到另一列表
unconfirmed_users=['alice','brian','candace']
confirmed_users=[]
while unconfirmed_users:
    current_user=unconfirmed_users.pop()

    print("Verifying user: "+current_user.title())
    confirmed_users.append(current_user)
print("\nThe following users have been confirmed:")
for confirmed_user in confirmed_users:
    print(confirmed_user.title())

# 7.3.2 删除列表中的所有某个元素

pets=['a','b','c','d','c','c']
print(pets)

while 'c' in pets:
    pets.remove('c')

print(pets)


# 7.3.3用户输入字典
responses={}
polling_active=True

while polling_active:
    name=input("\nWhat is your name?")
    response=input("Which mountain would you like to climb someday?")

    responses[name]=response
    repeat=input("Would you like to let another person respond?(yes/no)")
    if repeat=='no':
        polling_active=False

print("\n---Poll Results---")
for name, response in responses.items():
    print(name+' would like to climb '+response+".")
























if height>=36:
    print("\nYou're tall enough to ride!")
else:
    print("\nYou'll be able to ride when you're a little older.")



#7.3.3 用户输入字典
responses={}
polling_active=True

while polling_active:
    name=input("\nWhat is your name?")
    response=input("Which mountain would you like to climb someday?")

    responses[name]=response
    repeat=input("Would you like to let another person respond?(yes/no)")
    if repeat=='no':
        polling_active=False

print("\n---Poll Results---")
for name, response in responses.items():
    print(name+' would like to climb '+response+".")


